package com.example.teach.controller;

import com.example.teach.entity.Result;
import com.example.teach.entity.UserClass;
import com.example.teach.service.CourseService;
import com.example.teach.service.ScheduleService;
import com.example.teach.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/page")
    public Result page(@RequestParam(required=false) String teacherName,
                       @RequestParam(required=false) String className,
                       @RequestParam(required=false) Integer majorId,
                       @RequestParam(required=false) Integer courseId,
                       @RequestParam(required=false) Integer remaining,
                       @RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "10") Integer pageSize){
        return studentService.getPage(teacherName,className,majorId,courseId,remaining,pageNum,pageSize);
    }

    @PostMapping("choose")
    public Result choose(@RequestBody UserClass userClass){
        return studentService.add(userClass);
    }

    @PostMapping("reduce")
    public Result reduce(@RequestBody UserClass userClass){
        return studentService.reduce(userClass);
    }

    @GetMapping("classSchedule")
    public Result classSchedule(@RequestParam Integer userId){
        return studentService.selectClassSchedule(userId);
    }

}
